package sheetOperations;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import storage.FieldInfo;


public class FormatSheet {

	/**
	 * Takes a worksheet and resizes all rows and hides appropriate columns
	 * @param hssfWorkbook
	 * @param string
	 * @return
	 */
	public static HSSFWorkbook format(HSSFWorkbook hssfWorkbook, String string) {
		Object[] keyList = FieldInfo.getAllFieldNames();
		//Hide columns
		for(int i=0;i<FieldInfo.getAllFieldNames().length;i++){
			if(FieldInfo.getField((String)keyList[i]).origin){
				if(string.equals("DEST") && i!=FieldInfo.getCneeColumn() && i!=FieldInfo.getOriginColumn()){
					hssfWorkbook.getSheetAt(0).setColumnWidth(FieldInfo.getField((String)keyList[i]).column, 0);
				}
			}else{
				if(string.equals("ORIGIN") && i!=FieldInfo.getCneeColumn() && i!=FieldInfo.getOriginColumn()){
					hssfWorkbook.getSheetAt(0).setColumnWidth(FieldInfo.getField((String)keyList[i]).column, 0);
				}
			}
		}
		
		//for(int i=0;i<hssfWorkbook.getSheetAt(0).getLastRowNum();i++){
		//	hssfWorkbook.getSheetAt(0).getRow(i).setHeightInPoints(25);
		//}
		return hssfWorkbook;
	}

}
